package com.zygh.lz.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.lz.entity.Section;
import com.zygh.lz.vo.ResultBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SectionMapper extends BaseMapper<Section> {
    int deleteByPrimaryKey(Integer sysSectionId);

    int insert(Section record);

    int insertSelective(Section record);

    Section selectByPrimaryKey(Integer sysSectionId);

    int updateByPrimaryKeySelective(Section record);

    int updateByPrimaryKey(Section record);


    //查询所有部门
    List<Section> selectAllSection(String sectionname);

    //部门删除是判断
    int selectByPid(int Pid);

    //部门人员信息查询那里的模糊查询
    List<Section> selectSectionByCt(@Param("sex") String sex,
                                    @Param("staffHierarchy") String staffHierarchy,
                                    @Param("sectionName") String sectionName);

    //根据部门id查询所有部门人员
    List<Object> selectBySectionId(@Param("SectionId") Integer SectionId,
                                   @Param("staffHierarchy") String staffHierarchy);

    //根据大队id查询大队下面的中队   根据pid查询下级列表
    List<Section> selectDetachmentByid(Integer id);

    List<Section> findSelectBySublevel(@Param("id") Integer id,
                                       @Param("type") Integer type);


    /**
     * 通过id查询大队
     *
     * @param id   所属大队的id
     * @param type 类型
     * @return Section
     */
    Section selectByid(@Param("id") Integer id,
                       @Param("type") Integer type);


    Section findSectionByName(String name);


    List<Section> findSectionByid(Integer id);

    List<Section> findSectionByLochus(Integer id);

    List<Map<String, Object>> findSectionByXarea(Integer sectionId);

    Section findsectionByTempId(String tempId);

    //查询所有有岗位的大队
    List<Map> findSectionByBattation(String battalion);

    //查询所有有岗位的中队
    List<Map> findSectionBydetachment(String sectionId);

    //查询所有大队
    List<Map> findSectionDid(Integer id);

    List<Map> findSectionDids(Integer id);

    //查询所有中队队
    List<Map> findSectionZid(Integer id);

    //查询所有在线大队
    List<Map<String, Object>> findOnLineSection(Integer id);


    List<Integer> findSectionByPid(int id);

    List<Integer> findSectionNum(int id);

    String getRwid(String code);


    //首页警力分类列表
    List<Map<String, Object>> findSectionsByPid(Integer pid);

    @Select(" select sys_section_id, section_pid, section_name as sectionName, section_position, section_tel, section_person, rwzid, tempid, hotline, is_check, sort from section sc where  exists (select 1 from section se where se.section_pid = sc.section_pid)")
    List<Map> findSection(Integer sectionId1);

    @Select(" select  section_pid from section sc where sc.sys_section_id = #{sectionDid}")
    Integer findSectionPid(Integer sectionDid);
}